const { replyMessage } = require("../../replyMessage");
const { GXH_Reply } = require("../../gzhConst");
const { util } = require("utils");
const { encode } = require("../../tool/encode");
// 取消订阅
function debugDemoAction(xml, appId, nonce) {
    console.log("调试咯...", appId, nonce, xml);

    /*
    wx172bbac9c0ca3417 178463834
    {
        "ToUserName": "gh_277bf55051bb",
        "FromUserName": "oxWk-5vaskY0-jeEH3eVmUasQHxA",
        "CreateTime": 1724596257,
        "MsgType": "event",
        "Event": "debug_demo",
        "debug_str": "yiyiyi"
    }
    */

    // 要回复一下
    // 这里简单 文本回复一下就好
    let { FromUserName = "" } = xml || {};
    let content = `${FromUserName}, 调试调试`;
    // message 是组装好的  消息 对象
    let message = replyMessage(xml, GXH_Reply.Text, content);
    if (util.nilValue(message)) {
        return "";
    }
    // 处理加密
    let final = encode(message, appId, nonce);
    if (util.nilValue(final)) {
        return "";
    }
    return final;
}

module.exports = {
    debugDemoAction,
};
